/**
 * 安卓白金英雄坛制作组 <br>
 * 文件名：LuoYingBinFen.java <br>
 * 创建时间：2013-8-23 下午8:09:39 <br>
 * 所属项目：GmudEX <br>
 * @author 12548 <br>
 */
package lostland.gmud.exv2.battle.proc.stunt;

import com.orhanobut.logger.Logger;

import lostland.gmud.exv2.battle.BattleScreen;
import lostland.gmud.exv2.battle.ViewScreen;
import lostland.gmud.exv2.battle.proc.Status;
import lostland.gmud.exv2.battle.proc.StuntScreen;
import lostland.gmud.exv2.data.Item;
import lostland.gmud.exv2.data.Npc;
import lostland.gmud.exv2.data.Room;

/**
 * 类名：LuoYingBinFen <br>
 * 说明：17.花团鞭法·10.落英缤纷
 *
 * @author 12548
 */
public class LuoYingBinFen extends Status {


	/**
	 * @param zdp
	 * @param bdp
	 */
	public LuoYingBinFen(Npc zdp, Npc bdp) {
		super(zdp, bdp);
	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.battle.proc.Status#execute()
	 */
	@Override
	public void execute() {

		double hit_rate = 0.8 + 0.3 * (((double) zdp.getAttr(Room.ATTR_AGI) - bdp.getAttr(Room.ATTR_AGI)) / (zdp.getAttr(Room.ATTR_AGI) + bdp.getAttr(Room.ATTR_AGI)));

		Logger.i("命中率=" + hit_rate);

		boolean hit = Math.random() < hit_rate;

		if (hit) {
			if (Item.notNull(bdp.getAttackItem())) {
				new ViewScreen(BattleScreen.bsp(zdp, bdp, "$n手中兵刃被鞭圈带动连转几圈，再也把持不定，一下子脱手飞出！")).pushToGame();
				bdp.unequip(bdp.getAttackItem());
			} else {
				new ViewScreen(BattleScreen.bsp(zdp, bdp, "$n眼见漫天鞭影当头罩下，躲无可躲，架无可架，一下子卷入鞭圈之中！")).pushToGame();
				bdp.dmg((int) (Math.random() * 200 + 50), 0);
				bdp.setTransfixed(bdp.getDz() + 3);
			}
		} else {
			if (bdp.getAttackItem().getKind() == 2) {
				new ViewScreen(BattleScreen.bsp(zdp, bdp, "$n身手敏捷，见机急快，连忙随著鞭势运力抽出，锵的一声逃过兵刃被夺之厄！")).pushToGame();
			} else {
				new ViewScreen(BattleScreen.bsp(zdp, bdp, "$n眼见不好，紧急中一个就地十八滚，滚出数丈之外，却也大感狼狈！")).pushToGame();
			}
			zdp.setTransfixed(zdp.getDz() + 3);
		}

		StuntScreen.StuntOver();

	}

}
